<?php
$page = 'admin';
include '../database/connect.php';
if (isset($_GET['save'])) {
    session_start();
    extract($_POST);
    $added_by = $_SESSION['username'];
    $query = "INSERT INTO lessons SET course='$course', topic='$topic', content='$content',added_by='$added_by'";
    mysql_query($query) or die("Error executing '$query':" . mysql_error());
    header("Location: lessons.php");
}
?>
<?php require_once 'header.php'; ?>
<form action="?save=1" method="POST" id="lesson_form">
    <table class="table">
        <tr>
            <td >Course Name</td>
            <td>
                <?php
                $query = "SELECT * FROM courses order by course asc";
                $result = mysql_query($query) or die("Error executing '$query':" . mysql_error());
                echo '<select name="course">';
                while ($row = mysql_fetch_array($result)) {
                    echo "<option value='" . $row['course'] . "'>" . $row['course'] . "</option>";
                }

                echo '</select>'; // Close your drop down box
                ?>
            </td>
        </tr>
        <tr>
            <td >Topic</td>
            <td><input type="text" class="validate[required] wide" name="topic" id='topic'/></td>
        </tr>
        <tr>
            <td >Content</td>
            <td><textarea name="content" id='content' cols="60" rows="17"></textarea></td>
        </tr >
        <tr>
            <td colspan="2" style="text-align: right;"><input type="submit"/></td>
        </tr>
    </table>
</form>
<?php require_once('footer.php'); ?>